using Component;

namespace Entity
{
    /// <summary>
    /// 当试图对Entity中的Component操作时，Component不存在于该Entity时的报错
    /// </summary>

    class ComponentNotExistException : Exception
    {
        Type? componentType { get; }
        IEntity entity { get; }

        public ComponentNotExistException(Type _component, IEntity _entity)
        {
            componentType = _component;
            entity = _entity;
            Console.WriteLine($"{entity.GetType().Name}不包含组件{componentType.Name}");
        }
        public ComponentNotExistException(IComponent _component, IEntity _entity)
        {
            componentType = _component.GetType();
            entity = _entity;
            Console.WriteLine($"{entity.GetType().Name}不包含组件{componentType.Name}");
        }
        public ComponentNotExistException(int componentIndex, IEntity _entity)
        {
            entity = _entity;
            Console.WriteLine($"{entity.GetType().Name}不包含该组件(调用下标为{componentIndex})");
        }
    }
    class ComponentTypeNotFoundException : Exception
    {
        public ComponentTypeNotFoundException(Type componentType)
        {
            Console.WriteLine($"未找到组件类型{componentType.Name}");
        }
    }
}